/*
 * Funny Language - a free style programming language.
 * Copyright (C) 2015 by fanguangping (fanguangping@163.com)
 * cmemory.c
 */

#include <stdio.h>
#include <stdlib.h>
#include "cmemory.h"

void *sys_malloc (size_t __size) {
    void* p = malloc(__size);
    if (p == NULL) {
        fprintf(stderr, "out of memory!\n");
        exit(1);
    }
    return p;
}

void *sys_calloc (size_t __nmemb, size_t __size) {
    void* p = calloc(__nmemb, __size);
    if (p == NULL) {
        fprintf(stderr, "out of memory!\n");
        exit(1);
    }
    return p;
}

void *sys_realloc (void *__ptr, size_t __size) {
    void* p = realloc(__ptr, __size);
    if (p == NULL) {
        fprintf(stderr, "out of memory!\n");
        exit(1);
    }
    return p;
}

void sys_free (void *__ptr) {
    free(__ptr);
}
